import subprocess

epoch = 10
lr = 5e-4
name = "train"

cmd = [
    "accelerate", "launch",
    "--config_file", "cfg.yaml",
    "train.py",
    "--run_name", f"{name}_e{epoch}_l{lr}",
    "--model_path", "/data02/models/CodeLlama-7b-hf",
    "--train_dataset_path", f"./data/test_set_B/{name}.parquet",
    "--eval_dataset_path", f"./data/test_set_B/{name}.parquet",
    "--num_train_epochs", str(epoch),
    "--learning_rate", str(lr),
    "--output_dir", f"./checkpoints/{name}_e{epoch}_l{lr}",
    "--eval_steps", "50",
    "--save_steps", "100",
    "--max_length", "2048",
    "--per_device_train_batch_size", "1",
    "--per_device_eval_batch_size", "1"
]

try:
    process = subprocess.run(cmd, check=True)
except subprocess.CalledProcessError as e:
    print(f"命令执行失败: {e}")
except Exception as e:
    print(f"发生错误: {e}")